package org.tangolyricstagger.gui;

import org.apache.commons.lang.StringUtils;
import org.eclipse.jface.action.Action;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Shell;

public class DirectoryBrowseAction extends Action {
	Shell shell;
	SettingsDialog settings;

	public DirectoryBrowseAction(Shell shell, SettingsDialog settings) {
		this.shell = shell;
		this.settings = settings;
		setText("Browse...");
	}

	public void run() {
		DirectoryDialog directoryDialog = new DirectoryDialog(shell);
		directoryDialog.setFilterPath(settings.getDirectory().getText());
		String folder = directoryDialog.open();
		if (StringUtils.isNotBlank(folder)) {
			settings.getDirectory().setText(folder);
		}
	}

}
